package com.ken.common.utils;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import com.ken.common.pojo.captcha;

public class captchaUtil {
    public static captcha getCaptcha(){
        //1 通过工具生成图片验证码
        //hutool
        //int width, int height, int codeCount, int circleCount,分别为图片验证码的宽，高，验证码的位数，干扰线的位数
        CircleCaptcha circleCaptcha = CaptchaUtil.createCircleCaptcha(150, 48, 4, 20);
        String code = circleCaptcha.getCode();//4位验证码的值
        String imageBase64 = circleCaptcha.getImageBase64();//生成图片验证码的base64编码
        captcha captcha = new captcha();
        captcha.setCode(code);
        captcha.setCodeImage(imageBase64);
        return captcha;

    }
}
